# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=flickcurl
pkgver=1.26
pkgrel=12
pkgdesc="C library for the Flickr API"
arch=(loong64 x86_64)
url="http://librdf.org/flickcurl/"
license=(GPL)
depends=(curl libxml2 raptor)
makedepends=(gtk-doc)
source=(https://download.dajobe.org/flickcurl/${pkgname}-${pkgver}.tar.gz{,.asc}
        flickcurl-fix-off-by-one.patch::https://github.com/dajobe/flickcurl/commit/a99721524c3ad1afa128e9ec492921abc4bac1ff.patch
        flickcurl-fix-doublefree.patch::https://github.com/dajobe/flickcurl/commit/a5cc2a5d2fc7074f50fbaa772232b6e0fea7ce89.patch
        flickcurl-fix-tokeninit.patch::https://github.com/dajobe/flickcurl/commit/cce202afcf820918891251e1fa3801c7931b73ee.patch
        flickcurl-fix-argparsing.patch::https://github.com/dajobe/flickcurl/commit/b2d64c8289ef519e5265a73148b650b053cc0ae6.patch)
sha512sums=('5ffdef58e67cbf99da2e8eefad57e845627703d5b22c85d5635557cd2df53e47e74d8e3387523495708c5cc8952c290da5c4d5f1e86bd482312fc7e46e9af6cd'
            'SKIP'
            '9978f800d5cf731faf4f905c76badf5a5af6df6e8264668717a5df9518bd31b122ef9ec8ea44a96766f68aa3059ad8b6f0e4fa1be633141085dd95ec941a6a76'
            'd920c7397a57968623e60d2834fc4f57e7aa59fe5d42893e335c7042312947f1b5d7a6696c44a5195db252d3a8f117992ebc86fb1fc9a1d8e296b2b2062bb3de'
            'ebea1698d0e65c03221374489d5e7c85639cf87f79bd9cb58ed744ca57c3eca40c4c2d22c809d396729e58138da2952eedb6b1f0d630e3f382c4af3ea09fdae3'
            'd4c2c722208aaaf9b208101477d8c817695645d647290951ccc5a07d398133c1c8c23b87a74da29863394b1f280edde9695b0846317d49d2969c8e19b614f68d')
validpgpkeys=(F879F0DEDA780198DD08DC6443EC92504F71955A)

prepare() {
  cd ${pkgname}-${pkgver}
  for patch in off-by-one doublefree tokeninit argparsing
  do
      patch -p1 < ../flickcurl-fix-${patch}.patch
  done
  sed -i 's|#include <curl/types.h>||' src/flickcurl_internal.h
  autoreconf -vfi
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure --prefix=/usr
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
}
